

#include <iostream>
#include <string>
#include <stack>
#include <vector>
#include <numeric>
using namespace std;

class Solution
{
public:
    int calculate1(string s)
    {
        int n = s.size();
        char op = '+';
        stack<int> st;

        for (int i = 0; i < n;)
        {
            if (isblank(s[i]))
            {
                ++i;
                continue;
            }
            else if (isdigit(s[i]))
            {
                int tmp = 0;

                while (i < n && isdigit(s[i]))
                {
                    tmp = tmp * 10 + (s[i++] - '0');
                }
                if ('-' == op)
                    tmp = -tmp;
                st.push(tmp);

                if ('*' == op || '/' == op)
                {
                    tmp = st.top();
                    st.pop();

                    if ('*' == op)
                        st.top() *= tmp;
                    else
                        st.top() /= tmp;
                }
            }
            else
            {
                op = s[i++];
            }
        }

        int res = 0;
        while (st.size())
        {
            res += st.top();
            st.pop();
        }

        return res;
    }
    int calculate2(string s)
    {
        int n = s.size();
        char op = '+';
        vector<int> v;
        v.reserve(n);

        for (int i = 0; i < n;)
        {
            if (isblank(s[i]))
            {
                ++i;
                continue;
            }
            else if (isdigit(s[i]))
            {
                int tmp = 0;

                while (i < n && isdigit(s[i]))
                {
                    tmp = tmp * 10 + (s[i++] - '0');
                }
                if ('-' == op)
                    tmp = -tmp;
                v.push_back(tmp);

                if ('*' == op || '/' == op)
                {
                    tmp = v.back();
                    v.pop_back();

                    if ('*' == op)
                        v.back() *= tmp;
                    else
                        v.back() /= tmp;
                }
            }
            else
            {
                op = s[i++];
            }
        }

        return accumulate(v.begin(), v.end(), 0);
    }

    int pivotIndex1(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> dp(n);
        dp[0] = nums[0];

        int sum = accumulate(nums.begin(), nums.end(), 0);

        for (int i = 1; i < n; ++i)
        {
            dp[i] = dp[i - 1] + nums[i];
        }
        for (int i = 0; i < n; ++i)
        {
            if (dp[i] - nums[i] == sum - dp[i])
                return i;
        }

        return -1;
    }

    int pivotIndex2(vector<int>& nums)
    {
        int n = nums.size();

        for (int i = 0; i < n; ++i)
        {
            int sumL = 0, sumR = 0;

            for (int j = 0; j < i; ++j)
            {
                sumL += nums[j];
            }
            for (int j = i + 1; j < n; ++j)
            {
                sumR += nums[j];
            }

            if (sumL == sumR)
                return i;
        }

        return -1;
    }

    int pivotIndex3(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> dpL(n), dpR(n);

        dpL[0] = dpR[n - 1] = 0;
        for (int i = 1; i < n; ++i)
        {
            dpL[i] = dpL[i - 1] + nums[i - 1];
        }
        for (int i = n - 2; i >= 0; --i)
        {
            dpR[i] = dpR[i + 1] + nums[i + 1];
        }

        for (int i = 0; i < n; ++i)
        {
            if (dpL[i] == dpR[i])
                return i;
        }

        return -1;
    }
};

void Test1()
{
    string s("3+2*2");

    cout << Solution().calculate1(s) << endl;
}

void Test2()
{
#if 0
    int n = 0, q = 0;
    int l = 0, r = 0;

    cin >> n >> q;
    vector<int> v(n);

    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }

    while (q--)
    {
        cin >> l >> r;

        if (l == r)
            cout << v[--l] << endl;
        else
        {
            cout << accumulate(v.begin() + l - 1, v.begin() + r, (long long)0) << endl;
        }
    }
#endif
    int n = 0, q = 0;
    int l = 0, r = 0;

    cin >> n >> q;
    vector<int> v(n + 1);
    vector<long long> dp(n + 1);

    for (int i = 1; i <= n; ++i)
    {
        cin >> v[i];
        dp[i] = dp[i - 1] + v[i];
    }

    while (q--)
    {
        cin >> l >> r;

        cout << dp[r] - dp[l] + v[l] << endl;
    }
}

void Test3()
{
    int q = 0;
    int n = 0, m = 0;

    cin >> n >> m >> q;
    vector<vector<int>> vv(n + 1, vector<int>(m + 1));
    vector<vector<long long>> dp(n + 1, vector<long long>(m + 1));

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            cin >> vv[i][j];
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + vv[i][j];
        }
    }

    int x1 = 0, y1 = 0;
    int x2 = 0, y2 = 0;

    while (q--)
    {
        cin >> x1 >> y1 >> x2 >> y2;

        cout << dp[x2][y2] - dp[x2][y1 - 1] - dp[x1 - 1][y2] + dp[x1 - 1][y1 - 1] << endl;
    }
}

int main()
{
    //Test1();
    Test2();

	return 0;
}